import React from 'react';
import {Layout, Modal} from 'antd';
import './index.less';
import {connect} from "dva";
import Curd from "components/Curd";
import DataTable from "components/Base/DataTable";
import Button from "components/Base/Button";
import Icon from "components/Base/Icon";
import BaseComponent from "components/Base/BaseComponent";
import {getBpDeviceType, getEcgDeviceType} from "../../../models/deviceType";
import AutoEcg from "./AutoEcg";
const {Content, Footer, Header} = Layout;

@connect(({ecgSession}) => ({ecgSession}))
export default class extends BaseComponent {

  state = {
    visible: false,
  };

  getNamespace() {
    return 'ecgSession';
  }

  getTableColumns(self) {
    return [

      {
        title: '设备ID',
        name: 'numeration',
        tableItem: {
        },
      },

      {
        title: '心电型号',
        name: 'deviceType',
        dict: getEcgDeviceType(),
        tableItem: {},
      },
      {
        title: '运行模式',
        name: 'ecgDeviceRunMode',
        tableItem: {},
        dict: [
          {code: 'DIAGNOSIS_MODE', codeName: '诊断监护',},
          {code: 'STANDARD_MODE', codeName: '标准监护',},
          {code: 'SPORT_MODE', codeName: '运动监护模式',},
        ],
        formItem: {
          type: 'select',
        }
      },
      {
        title: '通道模式',
        name: 'ecgChannelType',
        tableItem: {},
        dict: [
          {code: 'CHAN_8', codeName: '8通道'},
          {code: 'CHAN_3', codeName: '3通道'},
          {code: 'CHAN_1', codeName: '1通道'},
        ],
        formItem: {
          type: 'select',
        }
      },
      {
        title: 'cpuId',
        name: 'cpuId',
        tableItem: {},
      },
      {
        title: '绑定患者',
        name: 'patientId',
        tableItem: {},
        formItem: {}
      },
      {
        title: '最后数据包时间',
        name: 'lastPacketTime',
        tableItem: {},
      },
      {
        title: '操作',
        tableItem: {
          render: (text, record) => {
            return (
              <DataTable.Oper>
                <AutoEcg  patientId={record.patientId} />
              </DataTable.Oper>
            );
          }
        },
      }
    ];
  }

  getSearchColumns() {
    return [{
      title: '设备id',
      name: 'deviceId',
      searchItem: {}
    }];
  }



  render() {


    const curdProps = {
      ...this.props,
      namespace: this.getNamespace(),
      tableColumns: this.getTableColumns,
      searchColumns: this.getSearchColumns,
      showAddDelete: false,
      pagination: true,
      align: 'center',
      selectType: 'none',
    }

    return (
      <Layout>
        <Content>
          <Curd {...curdProps}/>
        </Content>
      </Layout>
    );
  }

}
